<template>
  <div :class="{ smallFontSize: showEdition, mediumFontSize: !showEdition }" id="DJHJCSG">
    <p style="text-align: center; margin: 10px 0">地基和基础施工质量验收表</p>
    <table border="1" width="100%">
      <tr>
        <th colspan="5">验收内容</th>
        <th>设计要求及规程规定</th>
        <th>最小/实际抽样数量</th>
        <th>检查结果</th>
      </tr>
      <tr>
        <td rowspan="11">主控项目</td>
      </tr>
      <tr>
        <td>1</td>
        <td colspan="3">填料的配合比、分层铺设厚度与 夯打遍数</td>
        <td>
          第5.5.2条
          <!--<br />-->
          <!--显示-->
        </td>
        <td>全/</td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL1">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td rowspan="3">2</td>
        <td rowspan="3">水泥土 搅拌桩</td>
        <td colspan="2">水泥及外掺剂质量、用 量</td>
        <td rowspan="3">
          第5.5.3条
          <!--<br />-->
          <!--显示-->
        </td>
        <td>全/</td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL2">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td rowspan="2">强度检验</td>
        <td>成桩3d内</td>
        <td>全/</td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL3">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>成桩7d后</td>
        <td>全/</td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL4">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>3</td>
        <td colspan="3">基底土质、基槽尺寸</td>
        <td>
          第5.5.4条
          <!--<br />-->
          <!--显示-->
        </td>
        <td>全</td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL5">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>4</td>
        <td colspan="3">基础宽度、埋深</td>
        <td>
          第5.5.5条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL6">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>5</td>
        <td colspan="3">毛石强度等级</td>
        <td>
          第5.5.6条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL7">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>6</td>
        <td colspan="3">砂浆强度等级</td>
        <td>
          第5.5.7条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL8">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>7</td>
        <td colspan="3">毛石砌体灰缝砂浆饱满度</td>
        <td>
          第5.5.8条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL9">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>8</td>
        <td colspan="3">基础混凝土强度等级</td>
        <td>
          第5.5.9条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL10">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td rowspan="5">一般项目</td>
      </tr>
      <tr>
        <td>1</td>
        <td colspan="3">填料的有机质含量、粒径等</td>
        <td>
          第5.5.11条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL11">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>2</td>
        <td colspan="3">水泥土搅拌桩的桩顶标高、桩底 标高、桩位偏差、垂直度等</td>
        <td>
          第5.5.12条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL12">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>3</td>
        <td colspan="3">基础顶部标高、轴线位置</td>
        <td>
          第5.5.13条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL13">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr>
        <td>4</td>
        <td colspan="3">基槽（坑）回填</td>
        <td>
          第5.5.13条
          <!--<br />-->
          <!--显示-->
        </td>
        <td></td>
        <td>
          <van-radio-group v-model="DJJCData.JCJL14">
            <van-radio name="1">合格</van-radio>
            <van-radio name="0">不合格</van-radio>
          </van-radio-group>
        </td>
      </tr>
      <tr v-for="(item1, index1) in ImgData" :key="index1">
        <td style="text-align: left; padding: 10px" colspan="8">
          <span style="margin-right: 40%">{{ item1.name }}</span>
          <p>
            <van-uploader @click-upload="getList(item1)" :after-read="afterRead" :before-delete="delectFile" v-model="item1.fileList" multiple />
          </p>
        </td>
      </tr>
      <tr>
        <td style="text-align: left; padding: 10px" colspan="8">
          <p>
            <van-field
              :class="{
                smallFontSize: showEdition,
                mediumFontSize: !showEdition
              }"
              v-model="DJJCData.SGDWJCJG"
              placeholder="请填写检查结果"
              label="施工单位（工匠）检查结果" />
          </p>
          <div style="float: left">
            <p>
              <!-- <van-field
                :class="{
                  smallFontSize: showEdition,
                  mediumFontSize: !showEdition,
                }"
                v-model="DJJCData.SGDWJCRY"
                placeholder="请填写检查人员"
                label="检查人员："
              /> -->
              <qianzi :placeholder="'请填写检查人员'" :file="fileshouxie1" :GROUPGUID="`地基和基础施工质量验收表_施工单位检查人员`" :ROW_GUID="rowData.ROW_GUID"></qianzi>
            </p>
            <p>
              <van-field
                readonly
                clickable
                name="datetimePicker"
                :value="DJJCData.SGDWJCJGSJ"
                label="检查时间："
                placeholder="请选择检查时间"
                @click="showPickerq = true"
                :class="{
                  smallFontSize: showEdition,
                  mediumFontSize: !showEdition
                }" />
              <van-popup v-model="showPickerq" position="bottom">
                <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPickerq = false" @confirm="onConfirmRQ" />
              </van-popup>
              <!--                <van-field  v-model="DJJCData.SGDWJCJGSJ" label="检查时间："  />-->
            </p>
          </div>
        </td>
      </tr>
      <tr>
        <td style="text-align: left; padding: 10px" colspan="8">
          <p>
            <van-field
              :class="{
                smallFontSize: showEdition,
                mediumFontSize: !showEdition
              }"
              v-model="DJJCData.YZJCJG"
              placeholder="请填写验收结论"
              label=" 业主（监理）验收结论" />
          </p>
          <div style="float: left">
            <p>
              <!-- <van-field
                :class="{
                  smallFontSize: showEdition,
                  mediumFontSize: !showEdition,
                }"
                v-model="DJJCData.YZJCRY"
                placeholder="请填写检查人员"
                label="检查人员："
              /> -->
              <qianzi :placeholder="'请填写检查人员'" :file="fileshouxie1" :GROUPGUID="`地基和基础施工质量验收表_业主检查人员`" :ROW_GUID="rowData.ROW_GUID"></qianzi>
            </p>
            <p>
              <van-field
                readonly
                clickable
                name="datetimePicker"
                :value="DJJCData.YZJCJCSJ"
                label="检查时间："
                placeholder="请选择检查时间"
                @click="showPicker = true"
                :class="{
                  smallFontSize: showEdition,
                  mediumFontSize: !showEdition
                }" />
              <van-popup v-model="showPicker" position="bottom">
                <van-datetime-picker v-model="currentDate1" type="date" title="选择年月日" @cancel="showPicker = false" @confirm="onConfirmR" />
              </van-popup>
              <!--                <van-field :class="{smallFontSize:showEdition,mediumFontSize:!showEdition}" v-model="DJJCData.YZJCJCSJ" label="检查时间："  />-->
            </p>
          </div>
        </td>
      </tr>
      <tr>
        <td style="text-align: left; padding: 10px" colspan="8">
          <p>附件：</p>
          <p @click="seeFile" style="color: blue">《农民自建低层住宅结构施工及验收规程》和条文说明</p>
        </td>
      </tr>
    </table>
    <div class="footer" v-if="!$route.query.type">
      <van-button v-if="this.$store.state.isGJ && isTIjiao" style="margin-right: 10px" size="small" type="info" @click="handleClick(SaveData)">提交</van-button>
      <van-button v-if="!this.$store.state.isGJ" size="small" type="info" @click="save()">保存</van-button>
      <van-button v-else-if="rowData.OPTYPE == '60' && !isTIjiao" size="small" type="info" @click="save()">保存</van-button>
    </div>
    <van-popup v-model="shoulm1">
      <div class="con_box">
        <h3>{{ text1.title }}</h3>
        <p>{{ text1.message }}</p>
        <div class="btnv">
          <span @click="handleClose1()" v-if="text1.btn.cancelText">
            {{ text1.btn.cancelText }}
          </span>
          <span @click="handleOk1(SaveData)" v-if="text1.btn.okText">
            {{ text1.btn.okText }}
          </span>
        </div>
      </div>
    </van-popup>
    <van-popup v-model="shoulm">
      <div class="con_box">
        <h3>{{ text.title }}</h3>
        <p>{{ text.message }}</p>
        <div class="btnv">
          <span @click="handleClose()" v-if="text.btn.cancelText">
            {{ text.btn.cancelText }}
          </span>
          <span @click="handleOk(SaveData)" v-if="text.btn.okText">
            {{ text.btn.okText }}
          </span>
        </div>
      </div>
    </van-popup>
  </div>
</template>
<style lang="scss">
#DJHJCSG {
  height: 100vh;
  overflow: auto;
  .van-radio__label {
    width: 48px;
  }
  .footer {
    text-align: center;
    padding: 10px 0;
  }
  /*padding:  10px;*/
  table,
  table tr th,
  table tr td {
    border: 1px solid #000000;
    text-align: center;
  }
  .van-popup {
    border-radius: 10px;
    .con_box {
      width: 270px;
      line-height: 1;
      text-align: center;
      color: #4d5c82;
      padding: 15px;
      box-sizing: border-box;
      > h3 {
        font-size: 20px;
        margin-top: 10px;
        margin-bottom: 20px;
      }
      > p {
        font-size: 17px;
        margin-bottom: 30px;
      }
      .btnv {
        display: flex;
        justify-content: space-between;
        > span {
          display: block;
          width: 114px;
          background-color: #e0e5f5;
          text-align: center;
          line-height: 44px;
          font-size: 17px;
        }
        > span:last-of-type {
          background-color: #1288fe;
          color: #ffffff;
        }
      }
    }
  }
}
</style>
<script>
import { InsertDataView, dataServerOpenDataView, updateDataView, FileServerUpload, GetFileData, DelectFile, FileServerProxy, dataTransFilePreview, dataTransFile } from '../../../utils/api'
import qianzi from '../../../common/qianzi.vue'
import dd from 'gdt-jsapi'
export default {
  data() {
    return {
      tableData: '',
      groupGuids: '',
      IsSave: '',
      ImgData: [
        {
          name: '钢筋合格证照片',
          groupGuid: '8627fbf3-42bd-4106-8787-9a7b6c0ac765',
          fileList: []
        },
        {
          name: '水泥合格证照片',
          groupGuid: '3f19df15-7cee-41ee-b1d6-57feba9dfaf9',
          fileList: []
        },
        {
          name: '石子沙合格证照片',
          groupGuid: 'f406a6df-1dba-49e5-acbf-85498b0f5096',
          fileList: []
        },
        {
          name: '现场照片合格证照片',
          groupGuid: '7dc9e1f4-e16b-4be0-8c8c-d435d494883e',
          fileList: []
        }
      ],
      fileshouxie: [
        {
          title: '请填写检查人员',
          FileName: '无',
          groupGuid: `地基和基础施工质量验收表_施工单位检查人员`,
          fileList: []
        }
      ],
      fileshouxie1: [
        {
          title: '请填写检查人员',
          FileName: '无',
          groupGuid: `地基和基础施工质量验收表_业主检查人员`,
          fileList: []
        }
      ],
      isAdd: true,
      currentDate: new Date(),
      currentDate1: new Date(),
      showPickerq: false,
      showPicker: false,
      rowData: '',
      radio: '',
      DJJCData: {
        JCJL1: '1',
        JCJL2: '1',
        JCJL3: '1',
        JCJL4: '1',
        JCJL5: '1',
        JCJL6: '1',
        JCJL7: '1',
        JCJL8: '1',
        JCJL9: '1',
        JCJL10: '1',
        JCJL11: '1',
        JCJL12: '1',
        JCJL13: '1',
        JCJL14: '1',
        ROW_GUID: '',
        SGDWJCJG: '',
        SGDWJCJGSJ: '',
        SGDWJCRY: '',
        SGFZR: '',
        TO_ROW_GUID: '',
        YZJCJCSJ: '',
        YZJCJG: '',
        YZJCRY: '',
        YZQRZT: ''
      },
      showEdition: '',
      SaveData: '',
      isTIjiao: false,
      shoulm: false,
      text: {
        title: '提示',
        message: '请确认是否发起基槽验线验收申请?',
        btn: {
          okText: '确定',
          cancelText: '取消'
        }
      },
      text1: {
        title: '提示',
        message: '请确认是否需要更换工匠?',
        btn: {
          okText: '确定',
          cancelText: '取消'
        }
      },
      shoulm1: false
    }
  },
  methods: {
    handleClose() {
      this.shoulm = false
    },
    handleOk(data) {
      this.save('提交')
      //调用当前环节的接口
      if (this.$store.state.isGJ) {
        if (
          (this.$store.state.HJZT === 4 && data.proc_name != '定位放样') ||
          (this.$store.state.HJZT === 6 && data.proc_name != '基槽验线') ||
          (this.$store.state.HJZT === 8 && data.proc_name != '一层立模') ||
          (this.$store.state.HJZT === 7 && data.proc_name != '竣工验收')
        ) {
          this.$toast.fail('未到此环节!')
          // this.$notify({ type: "warning", message: "未到此环节!" });
        }
        if (this.$store.state.HJZT === 4 && data.proc_name == '定位放样') {
          //调用定位放样的接口
          // let parms = {
          //   bizGuid: '19ae6659d-523b-4572-b808-17c469e8eec1',
          //   wfGuid: '{612C9C60-8D18-4D23-BF32-E9D9D01BB0EA}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          setTimeout(() => {
            this.$router.push({
              path: '/TreeSelectZL',
              query: {
                data: { TASK_ID: this.tableData, isdwfy: 1 },
                data2: '定位放样'
              }
            })
          }, 500)
        } else if (this.$store.state.HJZT === 6 && data.proc_name == '基槽验线') {
          // let parms = {
          //   bizGuid: '475c5d81-e6aa-486f-a113-bd651a675d75',
          //   wfGuid: '{460B4B5F-C3C2-4D4D-A702-17D4B4A3252F}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          setTimeout(() => {
            this.$router.push({
              path: '/TreeSelectZL',
              query: {
                data: { TASK_ID: this.tableData, isjcyx: 1 },
                data2: '基槽验线'
              }
            })
          }, 500)
        } else if (this.$store.state.HJZT === 8 && data.proc_name == '一层立模') {
          // let parms = {
          //   bizGuid: '21bbc961-f41f-4a9a-827b-491ec569bc0e',
          //   wfGuid: '{7F042B34-7091-4884-A5D6-A615AE55497D}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          setTimeout(() => {
            this.$router.push({
              path: '/TreeSelectZL',
              query: {
                data: { TASK_ID: this.tableData, isyclm: 1 },
                data2: '一层立模'
              }
            })
          }, 500)
        } else if (this.$store.state.HJZT === 7 && data.proc_name == '竣工验收') {
          // let parms = {
          //   bizGuid: '647a2885-7dc1-44af-b57d-2d63c4ab2936',
          //   wfGuid: '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          setTimeout(() => {
            this.$router.push({
              path: '/TreeSelectZL',
              query: {
                data: { TASK_ID: this.tableData, isjgys: 1 },
                data2: '竣工验收'
              }
            })
          }, 500)
        }
      } else {
        if (
          (this.$store.state.HJZT === 4 && data.proc_name != '定位放样') ||
          (this.$store.state.HJZT === 6 && data.proc_name != '基槽验线') ||
          (this.$store.state.HJZT === 8 && data.proc_name != '一层立模') ||
          (this.$store.state.HJZT === 7 && data.proc_name != '竣工验收')
        ) {
          this.$toast.fail('未到此环节!')
          // this.$notify({ type: "warning", message: "未到此环节!" });
        }
        if (this.$store.state.HJZT === 4 && data.proc_name == '定位放样') {
          //调用定位放样的接口
          // let parms = {
          //   bizGuid: '9ae6659d-523b-4572-b808-17c469e8eec1',
          //   wfGuid: '{612C9C60-8D18-4D23-BF32-E9D9D01BB0EA}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          window.localStorage.setItem('isNHCW', 1)
          setTimeout(() => {
            this.$router.push({
              path: '/TreeSelect',
              query: {
                data: this.tableData,
                isdwfy: 1
              }
            })
          }, 500)
        } else if (this.$store.state.HJZT === 6 && data.proc_name == '基槽验线') {
          // let parms = {
          //   bizGuid: '475c5d81-e6aa-486f-a113-bd651a675d75',
          //   wfGuid: '{460B4B5F-C3C2-4D4D-A702-17D4B4A3252F}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          window.localStorage.setItem('isNHCW', 1)
          setTimeout(() => {
            this.$router.push({
              path: '/TreeSelect',
              query: {
                data: this.tableData,
                isjcyx: 1
              }
            })
          }, 500)
        } else if (this.$store.state.HJZT === 8 && data.proc_name == '一层立模') {
          // let parms = {
          //   bizGuid: '21bbc961-f41f-4a9a-827b-491ec569bc0e',
          //   wfGuid: '{7F042B34-7091-4884-A5D6-A615AE55497D}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          window.localStorage.setItem('isNHCW', 1)
          setTimeout(() => {
            this.$router.push({
              path: '/TreeSelect',
              query: {
                data: this.tableData,
                isyclm: 1
              }
            })
          }, 500)
        } else if (this.$store.state.HJZT === 7 && data.proc_name == '竣工验收') {
          // let parms = {
          //   bizGuid: '647a2885-7dc1-44af-b57d-2d63c4ab2936',
          //   wfGuid: '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          window.localStorage.setItem('isNHCW', 1)
          setTimeout(() => {
            this.$router.push({
              path: '/TreeSelect',
              query: {
                data: this.tableData,
                isjgys: 1
              }
            })
          }, 500)
        }
      }
    },
    handleClose1() {
      if (this.IsSave) {
        // this.shoulm1 = false;
        this.shoulm = true
      } else {
        this.shoulm1 = false
        this.$toast.fail('工匠无提交《地基和基础施工质量验收表》表单！')
      }
    },
    handleOk1(data) {
      // this.handleButton();
      //更换工匠 标识
      window.sessionStorage.setItem('ChangeGJ', true)
      //跳入更换工匠页面
      this.$router.push({
        path: 'craftsmanServices',
        query: {
          id1: '更换工匠',
          dataValue: JSON.stringify(this.tableData)
        }
      })
    },
    delectFile: async function (file) {
      let fileguid = ''
      if (file.ROW_GUID) {
        fileguid = file.ROW_GUID
      } else {
        fileguid = this.fileGuid
      }
      if (fileguid) {
        let params = {
          accessCode: 'ce9b691634de4ebca68dc5bb638d07f4',
          cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
          params: {
            fileGuid: fileguid,
            token: window.localStorage.getItem('token')
          }
        }
        const res = await FileServerProxy(params)
        let data = JSON.parse(res.data.data).Success
        if (data) {
          this.$toast.success('删除成功!')
        }
      }
    },
    defaultField() {
      let dateTime
      let yy = new Date().getFullYear()
      let mm = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1
      let dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
      dateTime = yy + '-' + mm + '-' + dd
      this.DJJCData.YZJCJCSJ = dateTime
      this.DJJCData.SGDWJCJGSJ = dateTime
    },
    afterRead(file) {
      this.getFileServerUpload(file.file)
    },
    getFile: async function () {
      let groupGuid = []
      this.ImgData.forEach((item) => {
        groupGuid.push(item.groupGuid)
      })
      // const res1 = await GetFileData({
      //   groupGuid: groupGuid.join(","),
      //   toRowGuid: this.rowGuid,
      // });
      // if (res1.data.FilesInfo.length > 0) {
      //   res1.data.FilesInfo.forEach((element) => {
      //     this.ImgData.forEach((items) => {
      //       if (element.GROUPGUID == items.groupGuid) {
      //         element["isImage"] = true;
      //         element["url"] =
      //           window.g.BaseURL +
      //           "FileServer/api/Preview?token=" +
      //           window.localStorage.getItem("token") +
      //           "&" +
      //           "fileGuid=" +
      //           encodeURIComponent(element.ROW_GUID);
      //         items.fileList.push(element);
      //       }
      //     });
      //   });
      // }
      let params = {
        accessCode: '1fdcbce42c6d4748a020feba618d54b8',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          groupGuid: groupGuid.join(','),
          toRowGuid: this.rowGuid,
          token: window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(params)
      let data = JSON.parse(res.data.data).FilesInfo
      if (data.length > 0) {
        data.forEach((element) => {
          this.ImgData.forEach((items) => {
            if (element.GROUPGUID == items.groupGuid) {
              this.getFileUrl(element, items)
              // element["isImage"] = true;
              // element["url"] =
              //   window.g.BaseURL +
              //   "FileServer/api/Preview?token=" +
              //   window.localStorage.getItem("token") +
              //   "&" +
              //   "fileGuid=" +
              //   encodeURIComponent(element.ROW_GUID);
              // items.fileList.push(element);
            }
          })
        })
      }
    },
    //获取附件文件流
    getFileUrl: async function (element, item) {
      let formData = new FormData()
      formData.append('accessCode', '98bcf528966e48ce896a8b3fd02d45d5')
      formData.append('cityCode', window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000')
      formData.append(
        'paramStr',
        JSON.stringify({
          fileGuid: element.ROW_GUID
        })
      )
      let response = await dataTransFilePreview(formData)
      if (response) {
        var img = new Blob([new Int8Array(response.data, 0)], {
          type: response.headers['content-type']
        }) //type类型可自定义
        element['isImage'] = true
        element['url'] = window.URL.createObjectURL(img)
        item.fileList.push(element)
      }
    },
    getFileServerUpload: async function (file) {
      let data = {
        toRowGuid: this.rowGuid,
        groupGuid: this.groupGuids
        // token: window.localStorage.getItem('token')
      }
      let formData = new FormData()
      formData.append('file', file)
      formData.append('accessCode', '7a3fc061c866434b8475d3775c9ddcea')
      formData.append('cityCode', window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000')
      // formData.append('token', window.localStorage.getItem('token'))
      formData.append('paramStr', JSON.stringify(data))
      const res = await dataTransFile(formData)
      let data1 = JSON.parse(res.data.data).FileList
      this.fileGuid = data1[0].FILEGUID
      if (data1[0].FILEGUID) {
        this.$toast.success('上传成功!')
      }
    },
    getList(item) {
      this.groupGuids = item.groupGuid
    },
    onConfirmR(val) {
      let year = val.getFullYear()
      let month = val.getMonth() + 1
      let day = val.getDate()
      let hour = val.getHours()
      let minute = val.getMinutes()
      if (month >= 1 && month <= 9) {
        month = `0${month}`
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`
      }
      this.DJJCData.YZJCJCSJ = `${year}-${month}-${day}`
      this.showPicker = false
    },
    onConfirmRQ(val) {
      let year = val.getFullYear()
      let month = val.getMonth() + 1
      let day = val.getDate()
      let hour = val.getHours()
      let minute = val.getMinutes()
      if (month >= 1 && month <= 9) {
        month = `0${month}`
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`
      }
      this.DJJCData.SGDWJCJGSJ = `${year}-${month}-${day}`
      this.showPickerq = false
    },
    handleClick(data) {
      //判断有没有填写节点验收表
      // this.shoulm1 = true;
      debugger
      // this.rowGuid?.OPTYPE == '59'?this.shoulm1 = true:this.shoulm = true
      // if (this.tableData?.OPTYPE == '59') {
      //更换工匠 标识1
      // this.$confirm({
      //   title: '提示',
      //   message: '请确认是否需要更换工匠？',
      //   btn: {
      //     okText: '确定',
      //     cancelText: '取消'
      //   }
      // })
      //   .then(() => {
      //     // do something
      //     window.sessionStorage.setItem('ChangeGJ', true)
      //     //跳入更换工匠页面
      //     this.$router.push({
      //       path: 'craftsmanServices',
      //       query: {
      //         id1: '更换工匠',
      //         dataValue: JSON.stringify(this.tableData),
      //       },
      //     })
      //   })
      //   .catch(() => {
      //     console.log('no')
      //   })
      // } else {
      this.shoulm = true
      // }
    },
    getDDJCFromData: async function () {
      //调用存储过程
      let I_ROW_GUID = "'" + this.rowGuid + "'"
      let ghjbrexIsSave = {
        procName: 'up_query',
        dtParams: JSON.stringify([{ I_USERID: I_ROW_GUID, I_TYPE: 7 }]),
        token: window.localStorage.getItem('token')
      }
      let ghjbrfuIsSave = {
        accessCode: '69db6bece3a7480592e2ec753d1e335e',

        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: ghjbrexIsSave
      }
      const resghjbrbeisSave = await FileServerProxy(ghjbrfuIsSave)
      let IssaveData = JSON.parse(resghjbrbeisSave.data.data)
      if (IssaveData.Data && IssaveData.Data.length > 0 && IssaveData.Data[0].DATA == 0) {
        this.IsSave = false
      } else {
        this.IsSave = true
      }
    },
    save: async function (type) {
      // let data = this.DJJCData;
      // data.ROW_GUID = this.ROW_GUID;
      // data.TO_ROW_GUID = this.rowData.ROW_GUID;
      // let params = {
      //   dataGuid: "efa87d58-fa90-43d9-a8ea-a999f66850af",
      //   strParams: JSON.stringify([data]),
      //   token: window.localStorage.getItem("token"),
      // };
      // if (this.isAdd) {
      //   const res = await InsertDataView(params);
      //   if (res.data.Success) {
      //     this.$toast.success('成功！');
      //   }
      // } else {
      //   const res = await updateDataView(params);
      //   if (res.data.Success) {
      //     this.$toast.success('修改成功!');
      //   }
      // }
      let data = this.DJJCData
      data.ROW_GUID = this.ROW_GUID
      data.TO_ROW_GUID = this.rowData.ROW_GUID
      data.PKID = this.rowData.PKID
      let params = {
        accessCode: '',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataGuid: 'efa87d58-fa90-43d9-a8ea-a999f66850af',
          strParams: JSON.stringify([data]),
          token: window.localStorage.getItem('token')
        }
      }
      if (this.isAdd) {
        params.accessCode = '0fb3f6123d1b4fe6851c99532c463f6f'
        const res = await FileServerProxy(params)
        let data = JSON.parse(res.data.data).Success
        if (data && !type) {
          //点击提交的不提示
          this.$toast.success('成功！')
        }
      } else {
        params.accessCode = '77ad6c1591e54d4fbc45ecc90374a2a2'
        const res = await FileServerProxy(params)
        let data = JSON.parse(res.data.data).Success
        if (data && !type) {
          //点击提交的不提示
          this.$toast.success('修改成功!')
        }
      }
    },
    getData: async function () {
      // let dataGuid = "efa87d58-fa90-43d9-a8ea-a999f66850af";
      // let searchObject = encodeURIComponent(
      //   JSON.stringify([
      //     { field: "to_row_guid", value: this.rowData.ROW_GUID, operator: "=" },
      //   ])
      // );
      // let token = window.localStorage.getItem("token");
      // const res = await dataServerOpenDataView(dataGuid, searchObject, token);
      // if (res.data.Data.length > 0) {
      //   this.DJJCData = res.data.Data[0];
      // }
      // if (res.data.Data.length > 0) {
      //   this.ROW_GUID = res.data.Data[0].ROW_GUID;
      //   this.isAdd = false;
      // } else {
      //   this.ROW_GUID = this.newGuid();
      //   this.isAdd = true;
      // }
      // **************
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: 'efa87d58-fa90-43d9-a8ea-a999f66850af',
          searchObject: JSON.stringify([
            {
              field: 'to_row_guid',
              value: this.rowData.ROW_GUID,
              operator: '='
            }
          ]),
          token: window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(params)
      let data = JSON.parse(res.data.data).Data
      if (data.length > 0) {
        for (let i in this.DJJCData) {
          this.DJJCData[i] = data[0][i]
        }
      }
      if (data.length > 0) {
        this.ROW_GUID = data[0].ROW_GUID
        this.isAdd = false
      } else {
        this.ROW_GUID = this.newGuid()
        this.isAdd = true
      }
    },
    newGuid(format) {
      //表示全局唯一标识符 (GUID)。
      function Guid(g) {
        var arr = new Array() //存放32位数值的数组
        if (typeof g == 'string') {
          //如果构造函数的参数为字符串
          InitByString(arr, g)
        } else {
          InitByOther(arr)
        }
        //返回 Guid 类的此实例值的 String 表示形式。
        this.ToString = function (format) {
          if (typeof format == 'string') {
            if (format == 'N' || format == 'D' || format == 'B' || format == 'P') {
              return ToStringWithFormat(arr, format)
            } else {
              return ToStringWithFormat(arr, 'D')
            }
          } else {
            return ToStringWithFormat(arr, 'D')
          }
        }

        //由字符串加载
        function InitByString(arr, g) {
          g = g.replace(/\{|\(|\)|\}|-/g, '')
          g = g.toLowerCase()
          if (g.length != 32 || g.search(/[^0-9,a-f]/i) != -1) {
            InitByOther(arr)
          } else {
            for (var i = 0; i < g.length; i++) {
              arr.push(g[i])
            }
          }
        }

        //由其他类型加载
        function InitByOther(arr) {
          // var i = 32;
          // while (i--) {
          //     arr.push("0");
          // }

          var i = 32
          while (i--) {
            arr.push(Math.floor(Math.random() * 16.0).toString(16))
          }
        }

        /*
                  根据所提供的格式说明符，返回此 Guid 实例值的 String 表示形式。
                  N  32 位： xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                  D  由连字符分隔的 32 位数字 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                  B  括在大括号中、由连字符分隔的 32 位数字：{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
                  P  括在圆括号中、由连字符分隔的 32 位数字：(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
                  */

        //增加一个标识能区分开这个guid是不是由前端生成的
        function ToStringWithFormat(arr, format) {
          switch (format) {
            case 'N':
              return arr.toString().replace(/,/g, '')
            case 'D':
              var str = arr.slice(0, 8) + '-1203' + '-' + arr.slice(12, 16) + '-' + arr.slice(16, 20) + '-' + arr.slice(20, 32)
              str = str.replace(/,/g, '')
              return str
            case 'B':
              var str = ToStringWithFormat(arr, 'D')
              str = '{' + str + '}'
              return str
            case 'P':
              var str = ToStringWithFormat(arr, 'D')
              str = '(' + str + ')'
              return str
            default:
              return new Guid()
          }
        }

        return this.ToString()
      }

      var g = new Guid()
      return g.ToString(format)
    },
    seeFile() {
      if (ZWJSBridge) {
        ZWJSBridge.openLink({
          url: 'https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/文明.pdf'
        })
          .then((res) => {})
          .catch((err) => {
            window.open('https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/文明.pdf')
          })
        // }
      }
    }
  },
  components: {
    qianzi
  },
  mounted() {
    this.defaultField()
    this.rowData = JSON.parse(this.$route.query.data)
    this.rowGuid = this.rowData.ROW_GUID
    this.tableData = JSON.parse(this.$route.query.data)
    this.SaveData = JSON.parse(this.$route.query.data1)
    this.getData()
    this.getFile()
    this.showEdition = this.$store.state.Edition
    //获取是否填写
    if (this.$store.state.isGJ) {
      this.getDDJCFromData()
    }
    if (window.localStorage.getItem('isPerTab') == 2) {
      this.isTIjiao = false
    } else {
      debugger
      this.isTIjiao = true
    }
    console.log(this.isTIjiao, this.$store.state.isGJ)
  }
}
</script>
